package com.mzj.saas.mservice.eligible.service;

import com.mzj.saas.mservice.eligible.entity.DepartmentHierarchy;
import com.mzj.saas.mservice.eligible.repository.DepartmentHierarchyRepository;
import com.mzj.saas.mservice.sys.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DepartmentHierarchyService {

	@Autowired
	private UserService userService;
	@Autowired
	private DepartmentHierarchyRepository departmentHierarchyRepository;

	/**
	 * 根据企业下任意部门id获取一级企业id
	 * 
	 * @param orgId
	 * @return
	 * @author shun
	 * @date 2021年6月24日
	 */
	public DepartmentHierarchy getEnterpriseInfo(Long orgId) {
		Long enterpriseId = userService.findCompanyByUserDepId(orgId);
		if (enterpriseId == null) {
			return null;
		}
		return departmentHierarchyRepository.findByOrgId(enterpriseId);
	}
}
